<template>
  <div class="app-container">
    <el-form
      :model="config"
      ref="form"
      size="small"
      :rules="rules"
      :inline="true"
      label-width="120px"
    >
      <el-row>
        <el-form-item label="首页配置社群数量" prop="homeNum1">
          <el-input-number v-model="form.homeNum1" :min="1" />
        </el-form-item>
      </el-row>
      <el-row>
        <el-form-item label="首页配置人脉数量" prop="homeNum2">
          <el-input-number v-model="form.homeNum2" :min="1" />
        </el-form-item>
      </el-row>
      <el-row>
        <el-form-item label="首页配置商机数量" prop="homeNum3">
          <el-input-number v-model="form.homeNum3" :min="1" />
        </el-form-item>
      </el-row>
      <el-row>
        <el-form-item label="VIP顶置收费比例" prop="overheadVipFee">
          <el-input-number v-model="form.overheadVipFee" :min="1" />
        </el-form-item>
      </el-row>
      <el-row>
        <el-form-item label="普通用户顶置收费比例" prop="overheadFee">
          <el-input-number v-model="form.overheadFee" :min="1" />
        </el-form-item>
      </el-row>
      <el-row>
        <el-form-item label="默认头像配置" prop="overheadFee">
          <!-- <el-input-number v-model="form.avatar" :min="1" /> -->
        </el-form-item>
      </el-row>
      <el-form-item>
        <el-button
          type="primary"
          size="medium"
          v-hasPermi="['param:index:edit']"
          @click="updateKey"
          >修改</el-button
        >
      </el-form-item>
    </el-form>
  </div>
</template>

<script setup name="home">
import { getConfigByKeys, updateByKeys } from "@/api/main/common";
const { proxy } = getCurrentInstance();
const data = reactive({
  form: {},
  rules: {
    user: [{ required: true, message: "状态不能为空", trigger: "change" }],
    rule: [{ required: true, message: "状态不能为空", trigger: "change" }],
  },
});
const { form, rules } = toRefs(data);

function getKey() {
  getConfigByKeys("homeNum1,homeNum2,homeNum3").then((res) => {
    form.value = res.data;
  });
}

function updateKey() {
  updateByKeys(form.value).then((res) => {
    proxy.$modal.msgSuccess("修改成功");
  });
}

getKey();
</script>
